<?php
/**
 * Created by JetBrains PhpStorm.
 * User: zhenzhen
 * Date: 12-9-16
 * Time: 下午3:27
 * To change this template use File | Settings | File Templates.
 */
class izcooldisposeControl extends Control{
    function uploadiworks(){//处理上传作品
        $db=R('work_orig');
        $db->join=array(
            'work_imginfo'=>array(
                'type'=>'has_many',
                'foreign_key'=>'wid',
            ),
            'work_sort'=>array(
                'type'=>'has_many',
                'foreign_key'=>'wid',
            ),
            'work_color'=>array(
                'type'=>'has_many',
                'foreign_key'=>'wid',
            )
        );

        p($_POST);
        exit;
        //==============上传文件类================
        $up=new upload('./upload/data',array('rar','zip'));
        $upok=$up->upload();
;            $_POST['iworkfile']=$upok[0]['path'];//附件的地址
        $db->add();
        $wid=$db->get_insert_id();
          foreach($_POST['iworkcolor'] as $v){//插入选择的颜色
             $db->table('work_color');
             $db->add(array('wid'=>$wid,'colorid'=>$v));
           }
          foreach($_POST['iworksort'] as $sv){//插入选择的软件
              $db->table('work_sort');
              $db->add(array('wid'=>$wid,'sid'=>$sv));
          }
          foreach($_POST['uploadimg'] as $img){//插入图片的信息
              $db->table('work_imginfo');
              $db->add(array(
                  'wid'=>$wid,
                  'imgurl'=>$img[0],
                  'imgthumb1'=>$img[1],
                  'imgthumb2'=>$img[2],
                  'imginfo'=>$img[3],
              ));
          }

    }
}